package com.ssy.lingxi.product.repository.material;

import com.ssy.lingxi.product.entity.material.MaterialGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 物料组-Repository
 * @author hsl
 * @version 2.0.0
 * @date 22/03/22 16:28
 */
@Repository
public interface MaterialGroupRepository extends JpaRepository<MaterialGroup,Long>, JpaSpecificationExecutor<MaterialGroup> {
    boolean existsByMemberIdAndMemberRoleIdAndLevelAndName(Long memberId, Long memberId1, Integer level, String name);

    boolean existsByMemberIdAndMemberRoleIdAndLevelAndNameAndParentIdAndIdNot(Long memberId, Long memberId1, Integer level, String name, Long currentParentId, Long id);

    List<MaterialGroup> findByMemberIdAndMemberRoleIdAndParentId(Long memberId, Long memberRoleId, Long id);

    List<MaterialGroup> findByMemberIdAndMemberRoleIdAndFullIdStartingWith(Long memberId, Long memberRoleId, String fullId);

    List<MaterialGroup> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);

    List<MaterialGroup> findByMemberIdAndMemberRoleIdAndFullIdStartingWithAndIdNot(Long memberId, Long memberRoleId, String fullId, Long id);

}
